#include "UIImage.h"
#include "UIControlDes.h"
#include "ImageLocation.h"
#include "CImagePool.h"
#include "CMbmImage.h"

UIImage::UIImage() : iImage(NULL)
{
}

UIImage::~UIImage()
{
	iImage->Release();
}

void UIImage::Layout(TRect rc)
	{
	UIControl::Layout(rc);
	}

void UIImage::Draw(CGraphicsContext& aGc)
	{
	iImage->Draw((CBitmapContext&)aGc,iRect,TSize(0,0),100);
	}

TSize UIImage::GetControlSizeL()
	{
	if(iImage->IsLoaded())
		return iImage->GetSize();
	else
		return TSize(20,20);
	}

void UIImage::GetTagName(TDes8& aDes)
	{
	aDes.Copy(KCtrlImage);
	}

void UIImage::SetPropertyL(const TDesC& aProperty,const TDesC& aValue)
	{
	if(aProperty.Compare(KImagePropSrc) == 0)
		{
		THcImageLocation location;
		location.ParseImageSrc(aValue);
		iImage = CImagePool::Static()->Add(location);
		}
	else
		UIControl::SetPropertyL(aProperty,aValue);
	}